@extends('layouts.tankuang')

@section('content')
    <!--startprint-->
    <form name="add_form" id="add_form" method="post" action="{{url('admin/units/edit',$id)}}" enctype="multipart/form-data" style="overflow:hidden;height:100%;">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div id="div_print">
            <h2 class="text-center mg_b36 w mg_t25" style="font-weight: bold;">企事业单位基本情况登记表</h2>
            <table class="table-form table-border w mg-auto">
                <tbody>
                {{--@if($re->pic != '')
                    <tr>
                        <td class="font-bd" align="center" width="10%">单位图片</td>
                        <td colspan="5"><div class="example  col-md-12 col-xs-12 "><img src="{{ URL::asset('/') }}{{$re->pic}}" class="img-rounded" alt="" width="50"></div></td>
                    </tr>
                @endif--}}

                <tr>
                    <td class="font-bd" align="center" width="16%">单位名称</td>
                    <td colspan="3"><input type="text" class="form-input w" value="{{$re->name}}" name="name"></td>
                    <td rowspan="6" class="font-bd" align="center" width="10%">单位图片</td>
                    <td rowspan="6" style="width: 190px;">
                        @if($re->pic != '')
                            <div class="example" style="width: 190px;"><img src="{{ URL::asset('/') }}{{$re->pic}}" class="img-rounded" alt="" style="width: 190px;border-radius: 0;"></div>
                        @endif
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">原市、区、派出所</td>
                    <td colspan="3"><input type="text" class="form-input w" value="{{getValue($re->city,'area','id','name')}}{{getValue($re->area,'area','id','name')}}{{getValue($re->org_id,'area','id','name')}}" disabled></td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">新市、区、派出所</td>
                    <td colspan="3">
                        <div class="col-sm-3" style="margin-left: -15px;">
                            <select id="city" name="city" class="w150 input_all" style="width: 120px;">
                                <option value="">请选择</option>
                                @foreach($city as $v)
                                    <option value="{{$v->id}}">{{$v->name}}</option>
                                @endforeach
                            </select>
                        </div>
                        <div class="col-sm-3" style="margin-left:15px;">
                            <select id="area" name="area" class="w150 input_all" style="width: 120px;">
                                <option value="">请选择</option>
                            </select>
                        </div>
                        <div class="col-sm-3" style="margin-left:15px;">
                            <select id="org_id" name="org_id" class="w150 input_all" style="width: 120px;">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">详细地址</td>
                    <td colspan="3"><input type="text" class="form-input w"  value="{{$re->address}}" name="address"></td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">企业性质</td>
                    <td>
                        <select id="area" name="xingzhi" class="w150 input_all" style="width: 120px;">
                            <option value="">请选择</option>
                            <option value="国有" @if($re->xingzhi == '国有')selected @endif>国有</option>
                            <option value="私有" @if($re->xingzhi == '私有')selected @endif>私有</option>
                            <option value="股份" @if($re->xingzhi == '股份')selected @endif>股份</option>
                            <option value="合资" @if($re->xingzhi == '合资')selected @endif>合资</option>
                            <option value="外资" @if($re->xingzhi == '外资')selected @endif>外资</option>
                            <option value="个体" @if($re->xingzhi == '个体')selected @endif>个体</option>
                        </select>
                    </td>
                    <td class="font-bd" align="center">邮编</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->post_code}}" name="post_code">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">联系人</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->frdb_name}}" name="frdb_name">
                    </td>
                    <td class="font-bd" align="center">联系电话</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->frdb_phone}}" name="frdb_phone">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">分管保卫领导</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->fgbwld_name}}" name="fgbwld_name">
                    </td>
                    <td class="font-bd" align="center">职务</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->fgbwld_post}}" name="fgbwld_post">
                    </td>
                    <td class="font-bd" align="center">电话</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->fgbwld_phone}}" name="fgbwld_phone">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">保卫机构名称</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwjg_name}}" name="bwjg_name">
                    </td>
                    <td class="font-bd" align="center">人数</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwjg_num_of_peo}}" name="bwjg_num_of_peo">
                    </td>
                    <td class="font-bd" align="center">保卫专干</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwjg_zhuangan}}" name="bwjg_zhuangan">
                    </td>
                </tr>
                {{--<tr>
                    <td class="font-bd" align="center">护卫队人数</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->hwd_num_of_peo}}" name="hwd_num_of_peo">
                    </td>
                    <td class="font-bd" align="center">保安数</td>
                    <td colspan="3">
                        <input type="text" class="form-input" value="{{$re->baoan_num_of_peo}}" name="baoan_num_of_peo">
                    </td>
                </tr>--}}
                <tr>
                    <td class="font-bd" align="center">保卫负责人</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwfzr_name}}" name="bwfzr_name">
                    </td>
                    <td class="font-bd" align="center">职务</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwfzr_post}}" name="bwfzr_post">
                    </td>
                    <td class="font-bd" align="center">电话</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->bwfzr_phone}}" name="bwfzr_phone">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">职工总数</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->zhigong_num_of_peo}}" name="zhigong_num_of_peo">
                    </td>
                    <td class="font-bd" align="center">在职人数</td>
                    <td colspan="3">
                        <input type="text" class="form-input" value="{{$re->zaizhi_num_of_peo}}" name="zaizhi_num_of_peo">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">固定资产</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->gdzc}}" name="gdzc">
                    </td>
                    <td class="font-bd" align="center">经营状况</td>
                    <td colspan="3">
                        <input type="text" class="form-input" value="{{$re->jyzk}}" name="jyzk">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">重点要害部位</td>
                    <td>
                        <input type="text" class="form-input" value="{{$buwei_num}}" disabled>（处）
                    </td>
                    <td class="font-bd" align="center">要害部位工作人员数</td>
                    <td colspan="3">
                        <input type="text" class="form-input" value="{{$gzry_num}}" disabled>（人）
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">重点维稳工作对象</td>
                    <td>
                        <select class="w153 input_all" name="zdwwgzdx">
                            <option value="有" @if($re->zdwwgzdx == '有') selected @endif>有</option>
                            <option value="无" @if($re->zdwwgzdx == '无') selected @endif>无</option>
                        </select>
                    </td>
                    <td class="font-bd" align="center">数量</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->zdwwgzdx_num_of_peo}}" name="zdwwgzdx_num_of_peo">（人）
                    </td>
                    <td class="font-bd" align="center">其中骨干</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->zdwwgzdx_gg_num_of_peo}}" name="zdwwgzdx_gg_num_of_peo">（人）
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">单位类型</td>
                    <td>
                        <select class="w153 input_all" name="type">
                            <option value="">请选择单位类型</option>
                            @foreach($type as $k=>$v)
                                <option value="{{$v->id}}" @if($re->type == $v->id) selected @endif>{{$v->name}}</option>
                            @endforeach
                        </select>
                    </td>
                    <td class="font-bd" align="center">经度</td>
                    <td>
                        <input type="text" class="form-input" name="jd" value="{{$re->jd}}">
                    </td>
                    <td class="font-bd" align="center">纬度</td>
                    <td>
                        <input type="text" class="form-input" name="wd" value="{{$re->wd}}">
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">重点级别设置</td>
                    <td>
                        <select class="w153 input_all" name="is_imp">
                            <option value="0" @if($re->is_imp == 0) selected @endif>一般单位</option>
                            <option value="1" @if($re->is_imp == 1) selected @endif>省级重点单位</option>
                            <option value="2" @if($re->is_imp == 2) selected @endif>市级重点单位</option>
                            <option value="3" @if($re->is_imp == 3) selected @endif>县区级重点单位</option>
                        </select>
                    </td>
                    <td class="font-bd" align="center">组织机构代码</td>
                    <td>
                        <input type="text" class="form-input" name="zuzhijigou" value="{{$re->zuzhijigou}}">
                    </td>
                    <td class="font-bd" align="center">单位状态</td>
                    <td>
                        <select class="w153 input_all" name="is_del">
                            <option value="0" @if($re->is_del == 1) selected @endif>实有</option>
                            <option value="1" @if($re->is_del == 1) selected @endif>注销</option>
                            <option value="2" @if($re->is_del == 1) selected @endif>变更</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="font-bd" align="center">责任民警</td>
                    <td>
                        <select class="w153 input_all" name="minjing">
                            <option value="">请选择</option>
                            @foreach($police as $k=>$v)
                            <option value="{{$v->id}}" @if($re->minjing == $v->id) selected @endif>{{$v->name}}</option>
                            @endforeach
                        </select>
                    </td>
                    <td class="font-bd" align="center">民警电话</td>
                    <td>
                        <input type="text" class="form-input" value="{{$re->minjing_phone}}" name="minjing_phone">
                    </td>
                </tr>
                @foreach($field as $vv)
                <tr>
                    @foreach($vv as $v)
                        <td class="font-bd" align="center">{{$v->field_content}}</td>
                        <td>
                            @if($v->field_type == 1)
                                <input type="text" class="form-input" value="{{getFieldValue($re->id,$re->type,$v->id)}}" name="field[{{$v->field_name}}]">
                            @elseif($v->field_type == 2)
                                <select class="w153 input_all" name="field[{{$v->field_name}}]">
                                    <option value="">请选择</option>
                                    @foreach($v->daan as $v2)
                                        <option value="{{$v2->val}}" @if(getFieldValue($re->id,$re->type,$v->id) == $v2->val) selected @endif>{{$v2->val}}</option>
                                    @endforeach
                                </select>
                            @endif
                        </td>
                    @endforeach
                </tr>
                @endforeach
                <tr><td colspan="6" style="background-color: #69CEE9;text-align: center">单位信息</td></tr>

                <tr>
                    <td class="font-bd" align="center">备注</td>
                    <td colspan="5">
                        <textarea class="textarea">{{$re->remark}}</textarea>
                    </td>
                </tr>
                </tbody>
            </table>
            <!--endprint-->
            <div class="w wbt mg_t25 pd_b60 text-center">
                <button id="go" type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-save'">确定</button>
                <a id="goToPageB" class="easyui-linkbutton dsp print" data-options="iconCls:'icon-print'" onclick="getjwd()">点击获取经纬度</a>
                <a href="{{url('admin/units/print_unit',$id)}}" target="_blank" id="goToPageB" class="easyui-linkbutton dsp print" data-options="iconCls:'icon-print'">跳转至打印</a>
                <div class="box_bt">
                	<span class="img_add"><img src="{{ URL::asset('/') }}/css/icons/pencil.png">修改单位图片</span>
                  	 <input class="box_file" type="file" name="pic">
                </div>
                <!--<button type="button" class="easyui-linkbutton dsp" data-options="iconCls:'icon-no'" onclick="$('#w').window('close')">关闭</button>-->
            </div>
        </div>
    </form>

    <div id="jwd" class="easyui-window" closed="true" title="新增" data-options="iconCls:'icon-save'" style="width:700px;height:500px;padding:10px;">

    

    <link rel="stylesheet" href="{{ URL::asset('/') }}css/zoomify.min.css">
    <script src="{{ URL::asset('/') }}js/zoomify.min.js"></script>
    <script type="text/javascript">
        $('.example img').zoomify(function(){
            $(this).css({'position':'absolute','top':0,'bottom':0,'left':0,'right':0,'z-index':'9999',})
        });
    </script>
        <script type="text/javascript">
            $(document).on("change",'#city', function(){

                $('#area option:gt(0)').remove();
                $('#org_id option:gt(0)').remove();
                //alert(1);die;
                var cid = $("#city").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#area").append(option);
                        });
                    }
                });
            });

            $(document).on("change",'#area', function(){
                $('#org_id option:gt(0)').remove();
                var cid = $("#area").val();
                var url = "{{url('admin/getArea')}}";
                $.getJSON(url,{cid:cid},function(json){
                    /*清空原有的选项*/
                    if(json != ''){
                        $.each(json,function(index,array){
                            var option = "<option value='"+array['id']+"'";
                            option += ">"+array['name']+"</option>";
                            $("#org_id").append(option);
                        });
                    }
                });
            });
        </script>
    <script>
        $('#go').click(function (){
            var formData = new FormData($("#add_form")[0]);
            $.ajax({
                type: "POST",
                url: "{{url('admin/units/edit',$id)}}",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                success: function(data) {
                    if(data.status == 1){
                        $.messager.alert('信息提示',data.msg,'info');
                        $('#w').dialog('close');
                        $('.pagination-load').click();
                    }else{
                        $.messager.alert('信息提示',data.msg,'info');
                    }
                }
            });
        });
    </script>
    <script type="text/javascript">
        function doPrint() {
            /*bdhtml=window.document.body.innerHTML;
            sprnstr="<!--startprint-->";
            eprnstr="<!--endprint-->";
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
            window.document.body.innerHTML=prnhtml;
            window.print();*/

            winname = window.open('', "_blank",'');
            bdhtml=window.document.body.innerHTML;
            sprnstr="<!--startprint-->";
            eprnstr="<!--endprint-->";
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
            winname.document.body.innerHTML=prnhtml;
            winname.print();
        }
    </script>

    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=hrVnXxLAGVr6QZ0rt9MaxU8bBkwKzyQC"></script>
    <script type="text/javascript">
        function getjwd(){
            $('#jwd').window({
                title: "获取经纬度",
                href: '/admin/units/getjwd',
                width:'700',
                height:'500',
                minimizable:false,
                top:($(window).height() - 500) * 0.5,
                left:($(window).width() - 700) * 0.5,
                modal:true,
                closed: false,
            });
        }
    </script>
@stop